﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class but_control_MenuTrail : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            bindMenu();
        }
    }
    public void bindMenu()
    {
        QuanTriDAO qt = new QuanTriDAO();
        rptProductCategory.DataSource = qt.sanpham_nhom_getall("1");
        rptProductCategory.DataBind();
        rptNewsCategory.DataSource = qt.TinTuc_nhom_getall("1");
        rptNewsCategory.DataBind();
        //ds.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;
        //ds.SelectCommand = "sanpham_nhom_getall";
        //ds.SelectParameters.Clear();
        //ds.SelectParameters.Add(new Parameter("IsUsed"));
        //ds.SelectParameters["IsUsed"].DefaultValue = "1";
        //rptProductCategory.DataSourceID = "ds";
        //rptProductCategory.DataBind();
    }


    public string formatStyle(string dangMa)
    {
        if(dangMa.Trim().Length==3){
            return "MenuTo";
        }
        else{
            return "MenuNho";
        }
    }
    public string formatLink(string id, string dangma, string name, string directlink)
    {
        if (!directlink.Equals("#"))
        {
            return "<a href=\"" + directlink + "\">" + name + "</a>";
        }
        if (dangma.Trim().Length == 3)
        {
            return name;
        }
        else
        {
            return "<a href=\"Products.aspx?nhomId=" + id + "\">" + name + "</a>";
        }

    }
    public string formatLinkNews(string id, string dangma, string name, string directlink)
    {
        if (!directlink.Equals("#"))
        {
            return "<a href=\"" + directlink + "\">" + name + "</a>";
        }
        if (dangma.Trim().Length == 3)
        {
            return name;
        }
        else
        {
            return "<a href=\"News.aspx?nhomId=" + id + "\">" + name + "</a>";
        }

    }





}
